package com.xiaozhengkeji.blog.mapper;

import com.xiaozhengkeji.blog.entitys.UserEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserMapper {
    /**
     * 注册用户
     */
    @Insert("INSERT INTO blog_user(`email`, `password`, `ip`, `token`) VALUES (#{email}, #{password}, #{ip}, #{token})")
    int addUser(UserEntity userEntity);

    /**
     * 修改密码
     */
    @Update("update blog_user set `password`=#{password} where `id`=#{id}")
    int updateUserPassword(UserEntity userEntity);

    /**
     * 修改ip
     */
    @Update("update blog_user set `ip`=#{ip} where `id`=#{id}")
    int updateUserIp(UserEntity userEntity);

    /**
     * 修改token
     */
    @Update("update blog_user set `token`=#{token} where `id`=#{id}")
    int updateUserToKen(UserEntity userEntity);

    /**
     * 登陆判断
     */
    @Select("select * from blog_user where `email`=#{email} AND `password`=#{password}")
    UserEntity loginUser(String email, String password);
}
